blog

Home / DeveloperSection / Blogs / Create action sheet in iOS using UIAlertController in Objective-C

Create action sheet in iOS using UIAlertController in Objective-C

Sunil Singh7925 11-Jan-2017

You can create action sheet in iOS 8 or later version using UIAlertController .Following is the sample code for creating action sheet using UIAlertController-


UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Action Sheet" message:@"Action Sheet example using UIAlertController " preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"Cancel button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
NSLog(@"Delete button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Create" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"Create button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Select All" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"Select All button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[self presentViewController:actionSheet animated:YES completion:nil];


Following is the sample screen shot of action sheet using UIAlertController-


Create action sheet in iOS using UIAlertController in Objective-C


Updated 17-Mar-2018

Leave Comment

Comments

Liked By